| 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/::{pointrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/point()., Glyphrust-analyzer cargo ab_glyph 0.2.32 glyph/Glyph#, Pointrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point#, PxScaleFactorrust-analyzer cargo ab_glyph 0.2.32 scale/PxScaleFactor#}; |
| 4 | #[cfg(not(feature = "std"))] |
| 5 | use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/::Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#; |
| 6 | |
| 7 | /// A "raw" collection of outline curves for a glyph, unscaled & unpositioned. |
| 8 | #[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:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 9 | pub struct Outlinerust-analyzer cargo ab_glyph 0.2.32 outlined/Outline# { |
| 10 | /// Unscaled bounding box. |
| 11 | pub boundsrust-analyzer cargo ab_glyph 0.2.32 outlined/Outline#bounds.: Rectrust-analyzer cargo ab_glyph 0.2.32 outlined/Rect#, |
| 12 | /// Unscaled & unpositioned outline curves. |
| 13 | pub curvesrust-analyzer cargo ab_glyph 0.2.32 outlined/Outline#curves.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<OutlineCurverust-analyzer cargo ab_glyph 0.2.32 outlined/OutlineCurve#>, |
| 14 | } |
| 15 | |
| 16 | impl Outlinerust-analyzer cargo ab_glyph 0.2.32 outlined/Outline# { |
| 17 | /// Convert unscaled bounds into pixel bounds at a given scale & position. |
| 18 | /// |
| 19 | /// See [`OutlinedGlyph::px_bounds`]. |
| 20 | pub fn px_boundsrust-analyzer cargo ab_glyph 0.2.32 outlined/impl#[Outline]px_bounds().(&self, scale_factor: PxScaleFactorrust-analyzer cargo ab_glyph 0.2.32 scale/PxScaleFactor#, position: Pointrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point#) -> Rectrust-analyzer cargo ab_glyph 0.2.32 outlined/Rect# { |
| 21 | let Rectrust-analyzer cargo ab_glyph 0.2.32 outlined/Rect# { minrust-analyzer cargo ab_glyph 0.2.32 outlined/Rect#min., maxrust-analyzer cargo ab_glyph 0.2.32 outlined/Rect#max. } = self.boundsrust-analyzer cargo ab_glyph 0.2.32 outlined/Outline#bounds.; |
| 22 | |
| 23 | // Use subpixel fraction in floor/ceil rounding to eliminate rounding error |
| 24 | // from identical subpixel positions |
| 25 | let (x_trunc, x_fract) = (position.xrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point#x..truncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]trunc().(), position.xrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point#x..fractrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]fract().()); |
| 26 | let (y_trunc, y_fract) = (position.yrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point#y..truncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]trunc().(), position.yrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point#y..fractrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]fract().()); |
| 27 | |
| 28 | Rectrust-analyzer cargo ab_glyph 0.2.32 outlined/Rect# { |
| 29 | minrust-analyzer cargo ab_glyph 0.2.32 outlined/Rect#min.: pointrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/point().( |
| 30 | (min.xrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point#x. 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().scale_factor.horizontalrust-analyzer cargo ab_glyph 0.2.32 scale/PxScaleFactor#horizontal. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().x_fract).floorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]floor().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().x_trunc, |
| 31 | (min.yrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point#y. 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().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][Neg]neg().scale_factor.verticalrust-analyzer cargo ab_glyph 0.2.32 scale/PxScaleFactor#vertical. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().y_fract).floorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]floor().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().y_trunc, |
| 32 | ), |
| 33 | maxrust-analyzer cargo ab_glyph 0.2.32 outlined/Rect#max.: pointrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/point().( |
| 34 | (max.xrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point#x. 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().scale_factor.horizontalrust-analyzer cargo ab_glyph 0.2.32 scale/PxScaleFactor#horizontal. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().x_fract).ceilrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]ceil().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().x_trunc, |
| 35 | (max.yrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point#y. 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().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][Neg]neg().scale_factor.verticalrust-analyzer cargo ab_glyph 0.2.32 scale/PxScaleFactor#vertical. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().y_fract).ceilrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]ceil().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().y_trunc, |
| 36 | ), |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | /// A glyph that has been outlined at a scale & position. |
| 42 | #[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:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 43 | pub struct OutlinedGlyphrust-analyzer cargo ab_glyph 0.2.32 outlined/OutlinedGlyph# { |
| 44 | glyphrust-analyzer cargo ab_glyph 0.2.32 outlined/OutlinedGlyph#glyph.: Glyphrust-analyzer cargo ab_glyph 0.2.32 glyph/Glyph#, |
| 45 | // Pixel scale bounds. |
| 46 | px_boundsrust-analyzer cargo ab_glyph 0.2.32 outlined/OutlinedGlyph#px_bounds.: Rectrust-analyzer cargo ab_glyph 0.2.32 outlined/Rect#, |
| 47 | // Scale factor |
| 48 | scale_factorrust-analyzer cargo ab_glyph 0.2.32 outlined/OutlinedGlyph#scale_factor.: PxScaleFactorrust-analyzer cargo ab_glyph 0.2.32 scale/PxScaleFactor#, |
| 49 | // Raw outline |
| 50 | outlinerust-analyzer cargo ab_glyph 0.2.32 outlined/OutlinedGlyph#outline.: Outlinerust-analyzer cargo ab_glyph 0.2.32 outlined/Outline#, |
| 51 | } |
| 52 | |
| 53 | impl OutlinedGlyphrust-analyzer cargo ab_glyph 0.2.32 outlined/OutlinedGlyph# { |
| 54 | /// Constructs an `OutlinedGlyph` from the source `Glyph`, pixel bounds |
| 55 | /// & relatively positioned outline curves. |
| 56 | #[inline] |
| 57 | pub fn newrust-analyzer cargo ab_glyph 0.2.32 outlined/impl#[OutlinedGlyph]new().(glyph: Glyphrust-analyzer cargo ab_glyph 0.2.32 glyph/Glyph#, outline: Outlinerust-analyzer cargo ab_glyph 0.2.32 outlined/Outline#, scale_factor: PxScaleFactorrust-analyzer cargo ab_glyph 0.2.32 scale/PxScaleFactor#) -> Selfrust-analyzer cargo ab_glyph 0.2.32 outlined/impl#[OutlinedGlyph] { |
| 58 | // work this out now as it'll usually be used more than once |
| 59 | let px_bounds = outline.px_boundsrust-analyzer cargo ab_glyph 0.2.32 outlined/impl#[Outline]px_bounds().(scale_factor, glyph.positionrust-analyzer cargo ab_glyph 0.2.32 glyph/Glyph#position.); |
| 60 | |
| 61 | Selfrust-analyzer cargo ab_glyph 0.2.32 outlined/impl#[OutlinedGlyph] { |
| 62 | glyphrust-analyzer cargo ab_glyph 0.2.32 outlined/OutlinedGlyph#glyph., |
| 63 | px_boundsrust-analyzer cargo ab_glyph 0.2.32 outlined/OutlinedGlyph#px_bounds., |
| 64 | scale_factorrust-analyzer cargo ab_glyph 0.2.32 outlined/OutlinedGlyph#scale_factor., |
| 65 | outlinerust-analyzer cargo ab_glyph 0.2.32 outlined/OutlinedGlyph#outline., |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | /// Glyph info. |
| 70 | #[inline] |
| 71 | pub fn glyphrust-analyzer cargo ab_glyph 0.2.32 outlined/impl#[OutlinedGlyph]glyph().(&self) -> &Glyphrust-analyzer cargo ab_glyph 0.2.32 glyph/Glyph# { |
| 72 | &self.glyphrust-analyzer cargo ab_glyph 0.2.32 outlined/OutlinedGlyph#glyph. |
| 73 | } |
| 74 | |
| 75 | #[deprecated = "Renamed to `px_bounds`"] |
| 76 | #[doc(hidden)] |
| 77 | pub fn boundsrust-analyzer cargo ab_glyph 0.2.32 outlined/impl#[OutlinedGlyph]bounds().(&self) -> Rectrust-analyzer cargo ab_glyph 0.2.32 outlined/Rect# { |
| 78 | self.px_boundsrust-analyzer cargo ab_glyph 0.2.32 outlined/impl#[OutlinedGlyph]px_bounds().() |
| 79 | } |
| 80 | |
| 81 | /// Conservative whole number pixel bounding box for this glyph outline. |
| 82 | /// The returned rect is exactly large enough to [`Self::draw`] into. |
| 83 | /// |
| 84 | /// The rect holds bounding coordinates in the same coordinate space as the [`Glyph::position`]. |
| 85 | /// |
| 86 | /// Note: These bounds depend on the glyph outline. That outline is *not* necessarily bound |
| 87 | /// by the layout/`glyph_bounds()` bounds. |
| 88 | /// * The min.x bound may be greater or smaller than the [`Glyph::position`] x. |
| 89 | /// E.g. if a glyph at position x=0 has an outline going off to the left a bit, min.x will be negative. |
| 90 | /// * The max.x bound may be greater/smaller than the `position.x + h_advance`. |
| 91 | /// * The min.y bound may be greater/smaller than the `position.y - ascent`. |
| 92 | /// * The max.y bound may be greater/smaller than the `position.y - descent`. |
| 93 | /// |
| 94 | /// Pixel bounds coordinates should not be used for layout logic. |
| 95 | #[inline] |
| 96 | pub fn px_boundsrust-analyzer cargo ab_glyph 0.2.32 outlined/impl#[OutlinedGlyph]px_bounds().(&self) -> Rectrust-analyzer cargo ab_glyph 0.2.32 outlined/Rect# { |
| 97 | self.px_boundsrust-analyzer cargo ab_glyph 0.2.32 outlined/OutlinedGlyph#px_bounds. |
| 98 | } |
| 99 | |
| 100 | /// Draw this glyph outline using a pixel & coverage handling function. |
| 101 | /// |
| 102 | /// The callback will be called for each `(x, y)` pixel coordinate inside the bounds |
| 103 | /// with a coverage value indicating how much the glyph covered that pixel. |
| 104 | /// |
| 105 | /// A coverage value of `0.0` means the pixel is totally uncovered by the glyph. |
| 106 | /// A value of `1.0` or greater means fully covered. |
| 107 | pub fn drawrust-analyzer cargo ab_glyph 0.2.32 outlined/impl#[OutlinedGlyph]draw().<O: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(u32, u32, f32)>(&self, o: O) { |
| 108 | use ab_glyph_rasterizerrust-analyzer cargo ab_glyph_rasterizer 0.1.10 crate/::Rasterizerrust-analyzer cargo ab_glyph_rasterizer 0.1.10 raster/Rasterizer#; |
| 109 | let h_factor = self.scale_factorrust-analyzer cargo ab_glyph 0.2.32 outlined/OutlinedGlyph#scale_factor..horizontalrust-analyzer cargo ab_glyph 0.2.32 scale/PxScaleFactor#horizontal.; |
| 110 | let v_factor = -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][Neg]neg().self.scale_factorrust-analyzer cargo ab_glyph 0.2.32 outlined/OutlinedGlyph#scale_factor..verticalrust-analyzer cargo ab_glyph 0.2.32 scale/PxScaleFactor#vertical.; |
| 111 | let offset = self.glyphrust-analyzer cargo ab_glyph 0.2.32 outlined/OutlinedGlyph#glyph..positionrust-analyzer cargo ab_glyph 0.2.32 glyph/Glyph#position. rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Sub<Self>`]sub().-rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Sub<Self>`]sub(). rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Sub<Self>`]sub().self.px_boundsrust-analyzer cargo ab_glyph 0.2.32 outlined/OutlinedGlyph#px_bounds..minrust-analyzer cargo ab_glyph 0.2.32 outlined/Rect#min.; |
| 112 | let (w, h) = ( |
| 113 | self.px_boundsrust-analyzer cargo ab_glyph 0.2.32 outlined/OutlinedGlyph#px_bounds..widthrust-analyzer cargo ab_glyph 0.2.32 outlined/impl#[Rect]width().() as usize, |
| 114 | self.px_boundsrust-analyzer cargo ab_glyph 0.2.32 outlined/OutlinedGlyph#px_bounds..heightrust-analyzer cargo ab_glyph 0.2.32 outlined/impl#[Rect]height().() as usize, |
| 115 | ); |
| 116 | |
| 117 | let scale_up = |&Pointrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point# { xrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point#x., yrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point#y. }| pointrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/point().(x 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().h_factor, y 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().v_factor); |
| 118 | |
| 119 | self.outlinerust-analyzer cargo ab_glyph 0.2.32 outlined/OutlinedGlyph#outline. |
| 120 | .curvesrust-analyzer cargo ab_glyph 0.2.32 outlined/Outline#curves. |
| 121 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 122 | .foldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]fold().(Rasterizerrust-analyzer cargo ab_glyph_rasterizer 0.1.10 raster/Rasterizer#::newrust-analyzer cargo ab_glyph_rasterizer 0.1.10 raster/impl#[Rasterizer]new().(w, h), |mut rasterizer, curve| match curve { |
| 123 | OutlineCurverust-analyzer cargo ab_glyph 0.2.32 outlined/OutlineCurve#::Linerust-analyzer cargo ab_glyph 0.2.32 outlined/OutlineCurve#Line#(p0, p1) => { |
| 124 | // eprintln!("r.draw_line({:?}, {:?});", |
| 125 | // scale_up(p0) + offset, scale_up(p1) + offset); |
| 126 | rasterizer.draw_linerust-analyzer cargo ab_glyph_rasterizer 0.1.10 raster/impl#[Rasterizer]draw_line().(scale_up(p0) rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Add<Self>`]add().+rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Add<Self>`]add(). rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Add<Self>`]add().offset, scale_up(p1) rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Add<Self>`]add().+rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Add<Self>`]add(). rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Add<Self>`]add().offset); |
| 127 | rasterizer |
| 128 | } |
| 129 | OutlineCurverust-analyzer cargo ab_glyph 0.2.32 outlined/OutlineCurve#::Quadrust-analyzer cargo ab_glyph 0.2.32 outlined/OutlineCurve#Quad#(p0, p1, p2) => { |
| 130 | // eprintln!("r.draw_quad({:?}, {:?}, {:?});", |
| 131 | // scale_up(p0) + offset, scale_up(p1) + offset, scale_up(p2) + offset); |
| 132 | rasterizer.draw_quadrust-analyzer cargo ab_glyph_rasterizer 0.1.10 raster/impl#[Rasterizer]draw_quad().( |
| 133 | scale_up(p0) rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Add<Self>`]add().+rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Add<Self>`]add(). rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Add<Self>`]add().offset, |
| 134 | scale_up(p1) rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Add<Self>`]add().+rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Add<Self>`]add(). rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Add<Self>`]add().offset, |
| 135 | scale_up(p2) rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Add<Self>`]add().+rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Add<Self>`]add(). rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Add<Self>`]add().offset, |
| 136 | ); |
| 137 | rasterizer |
| 138 | } |
| 139 | OutlineCurverust-analyzer cargo ab_glyph 0.2.32 outlined/OutlineCurve#::Cubicrust-analyzer cargo ab_glyph 0.2.32 outlined/OutlineCurve#Cubic#(p0, p1, p2, p3) => { |
| 140 | // eprintln!("r.draw_cubic({:?}, {:?}, {:?}, {:?});", |
| 141 | // scale_up(p0) + offset, scale_up(p1) + offset, scale_up(p2) + offset, scale_up(p3) + offset); |
| 142 | rasterizer.draw_cubicrust-analyzer cargo ab_glyph_rasterizer 0.1.10 raster/impl#[Rasterizer]draw_cubic().( |
| 143 | scale_up(p0) rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Add<Self>`]add().+rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Add<Self>`]add(). rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Add<Self>`]add().offset, |
| 144 | scale_up(p1) rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Add<Self>`]add().+rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Add<Self>`]add(). rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Add<Self>`]add().offset, |
| 145 | scale_up(p2) rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Add<Self>`]add().+rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Add<Self>`]add(). rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Add<Self>`]add().offset, |
| 146 | scale_up(p3) rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Add<Self>`]add().+rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Add<Self>`]add(). rust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/impl#[Point][`Add<Self>`]add().offset, |
| 147 | ); |
| 148 | rasterizer |
| 149 | } |
| 150 | }) |
| 151 | .for_each_pixel_2drust-analyzer cargo ab_glyph_rasterizer 0.1.10 raster/impl#[Rasterizer]for_each_pixel_2d().(o); |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | impl AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<Glyphrust-analyzer cargo ab_glyph 0.2.32 glyph/Glyph#> for OutlinedGlyphrust-analyzer cargo ab_glyph 0.2.32 outlined/OutlinedGlyph# { |
| 156 | #[inline] |
| 157 | fn as_refrust-analyzer cargo ab_glyph 0.2.32 outlined/impl#[OutlinedGlyph][`AsRef<Glyph>`]as_ref().(&self) -> &Glyphrust-analyzer cargo ab_glyph 0.2.32 glyph/Glyph# { |
| 158 | self.glyphrust-analyzer cargo ab_glyph 0.2.32 outlined/impl#[OutlinedGlyph]glyph().() |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | /// Glyph outline primitives. |
| 163 | #[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:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 164 | pub enum OutlineCurverust-analyzer cargo ab_glyph 0.2.32 outlined/OutlineCurve# { |
| 165 | /// Straight line from `.0` to `.1`. |
| 166 | Linerust-analyzer cargo ab_glyph 0.2.32 outlined/OutlineCurve#Line#(Pointrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point#, Pointrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point#), |
| 167 | /// Quadratic Bézier curve from `.0` to `.2` using `.1` as the control. |
| 168 | Quadrust-analyzer cargo ab_glyph 0.2.32 outlined/OutlineCurve#Quad#(Pointrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point#, Pointrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point#, Pointrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point#), |
| 169 | /// Cubic Bézier curve from `.0` to `.3` using `.1` as the control at the beginning of the |
| 170 | /// curve and `.2` at the end of the curve. |
| 171 | Cubicrust-analyzer cargo ab_glyph 0.2.32 outlined/OutlineCurve#Cubic#(Pointrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point#, Pointrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point#, Pointrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point#, Pointrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point#), |
| 172 | } |
| 173 | |
| 174 | /// A rectangle, with top-left corner at `min`, and bottom-right corner at `max`. |
| 175 | #[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:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:, 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:)] |
| 176 | pub struct Rectrust-analyzer cargo ab_glyph 0.2.32 outlined/Rect# { |
| 177 | pub minrust-analyzer cargo ab_glyph 0.2.32 outlined/Rect#min.: Pointrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point#, |
| 178 | pub maxrust-analyzer cargo ab_glyph 0.2.32 outlined/Rect#max.: Pointrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point#, |
| 179 | } |
| 180 | |
| 181 | impl Rectrust-analyzer cargo ab_glyph 0.2.32 outlined/Rect# { |
| 182 | #[inline] |
| 183 | pub fn widthrust-analyzer cargo ab_glyph 0.2.32 outlined/impl#[Rect]width().(&self) -> f32 { |
| 184 | self.maxrust-analyzer cargo ab_glyph 0.2.32 outlined/Rect#max..xrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point#x. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().self.minrust-analyzer cargo ab_glyph 0.2.32 outlined/Rect#min..xrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point#x. |
| 185 | } |
| 186 | |
| 187 | #[inline] |
| 188 | pub fn heightrust-analyzer cargo ab_glyph 0.2.32 outlined/impl#[Rect]height().(&self) -> f32 { |
| 189 | self.maxrust-analyzer cargo ab_glyph 0.2.32 outlined/Rect#max..yrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point#y. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().self.minrust-analyzer cargo ab_glyph 0.2.32 outlined/Rect#min..yrust-analyzer cargo ab_glyph_rasterizer 0.1.10 geometry/Point#y. |
| 190 | } |
| 191 | } |