From 342f20bd72db7dcc72b506f2e20a8599cf984775 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Mon, 21 Oct 2024 18:43:31 +0700 Subject: [PATCH] Fix typos and add a CI check (#574) --- .github/workflows/ci.yml | 9 +++++++++ .typos.toml | 20 ++++++++++++++++++++ piet-cairo/src/text.rs | 2 +- piet-common/examples/mondrian.rs | 4 ++-- piet-coregraphics/src/lib.rs | 6 +++--- piet-direct2d/src/dwrite.rs | 2 +- piet-direct2d/src/text.rs | 4 ++-- piet-svg/src/lib.rs | 2 +- piet-svg/src/text.rs | 2 +- piet-web/src/text.rs | 2 +- piet-web/src/text/grapheme.rs | 2 +- piet/src/gradient.rs | 2 +- piet/src/image.rs | 2 +- piet/src/render_context.rs | 2 +- piet/src/samples/mod.rs | 2 +- piet/src/samples/picture_12.rs | 4 ++-- piet/src/shapes.rs | 4 ++-- piet/src/text.rs | 2 +- 18 files changed, 51 insertions(+), 22 deletions(-) create mode 100644 .typos.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15af3f64..b6fe38aa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -216,6 +216,15 @@ jobs: - name: cargo doc piet-web run: cargo doc --manifest-path=piet-web/Cargo.toml --all-features --document-private-items --target wasm32-unknown-unknown + # If this fails, consider changing your text or adding something to .typos.toml + typos: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: check typos + uses: crate-ci/typos@v1.26.0 + compare-snapshots: runs-on: ${{ matrix.os }} strategy: diff --git a/.typos.toml b/.typos.toml new file mode 100644 index 00000000..40ffbe21 --- /dev/null +++ b/.typos.toml @@ -0,0 +1,20 @@ +# See the configuration reference at +# https://github.com/crate-ci/typos/blob/master/docs/reference.md + +# Corrections take the form of a key/value pair. The key is the incorrect word +# and the value is the correct word. If the key and value are the same, the +# word is treated as always correct. If the value is an empty string, the word +# is treated as always incorrect. + +# Match Identifier - Case Sensitive +[default.extend-identifiers] + +# Match Inside a Word - Case Insensitive +[default.extend-words] + +[files] +# Include .github, .cargo, etc. +ignore-hidden = false +# /.git isn't in .gitignore, because git never tracks it. +# Typos doesn't know that, though. +extend-exclude = ["/.git"] diff --git a/piet-cairo/src/text.rs b/piet-cairo/src/text.rs index a5f8bcfe..6a6382c7 100644 --- a/piet-cairo/src/text.rs +++ b/piet-cairo/src/text.rs @@ -167,7 +167,7 @@ impl Text for CairoText { type TextLayoutBuilder = CairoTextLayoutBuilder; fn font_family(&mut self, family_name: &str) -> Option { - //TODO: Veryify that a family exists with the requested name + //TODO: Verify that a family exists with the requested name Some(FontFamily::new_unchecked(family_name)) } diff --git a/piet-common/examples/mondrian.rs b/piet-common/examples/mondrian.rs index 4ca3de3b..f39d88a9 100644 --- a/piet-common/examples/mondrian.rs +++ b/piet-common/examples/mondrian.rs @@ -50,11 +50,11 @@ fn main() { /// Generate a Piet Mondrian-style picture. /// /// Obviously we cannot recreate the genius of an artist with a simple random -/// generation, but the following makes something plausable (heavily influenced by +/// generation, but the following makes something plausible (heavily influenced by /// https://generativeartistry.com/tutorials/piet-mondrian/): /// /// 1. Start with a single rectangle covering the whole picture. -/// 2. Choose a number `n`. Choose `n` coordinates in the rectange. +/// 2. Choose a number `n`. Choose `n` coordinates in the rectangle. /// 3. For each coordinate `p`: split any rectangles who are intersected by the /// vertical or horizontal lines that cross `p`. Skip if this would create a /// very thin rectangle, or randomly some of the time. diff --git a/piet-coregraphics/src/lib.rs b/piet-coregraphics/src/lib.rs index d277b571..685b3f91 100644 --- a/piet-coregraphics/src/lib.rs +++ b/piet-coregraphics/src/lib.rs @@ -58,11 +58,11 @@ pub struct CoreGraphicsContext<'a> { impl<'a> CoreGraphicsContext<'a> { /// Create a new context with the y-origin at the top-left corner. /// - /// This is not the default for CoreGraphics; but it is the defualt for piet. + /// This is not the default for CoreGraphics; but it is the default for piet. /// To map between the two coordinate spaces you must also pass an explicit /// height argument. /// - /// The optional `text` argument can be a reuseable `CoreGraphicsText` struct; + /// The optional `text` argument can be a reusable `CoreGraphicsText` struct; /// a new one will be constructed if `None` is passed. pub fn new_y_up( ctx: &mut CGContextRef, @@ -76,7 +76,7 @@ impl<'a> CoreGraphicsContext<'a> { /// /// This is the default for core graphics, but not for piet. /// - /// The optional `text` argument can be a reuseable `CoreGraphicsText` struct; + /// The optional `text` argument can be a reusable `CoreGraphicsText` struct; /// a new one will be constructed if `None` is passed. pub fn new_y_down( ctx: &mut CGContextRef, diff --git a/piet-direct2d/src/dwrite.rs b/piet-direct2d/src/dwrite.rs index 43f593f8..510e6b37 100644 --- a/piet-direct2d/src/dwrite.rs +++ b/piet-direct2d/src/dwrite.rs @@ -395,7 +395,7 @@ impl TextLayout { } } - pub(crate) fn set_foregound_brush(&mut self, range: Utf16Range, brush: Brush) { + pub(crate) fn set_foreground_brush(&mut self, range: Utf16Range, brush: Brush) { unsafe { self.0 .SetDrawingEffect(brush.as_raw() as *mut IUnknown, range.into()); diff --git a/piet-direct2d/src/text.rs b/piet-direct2d/src/text.rs index e3091fc9..936d4811 100644 --- a/piet-direct2d/src/text.rs +++ b/piet-direct2d/src/text.rs @@ -271,7 +271,7 @@ impl D2DTextLayoutBuilder { layout.set_font_collection(utf16_range, loaded.collection()); } else if !self.loaded_fonts.inner.borrow().is_empty() { // if we are using custom fonts we also need to set the collection - // back to the system collection explicity as needed + // back to the system collection explicitly as needed layout.set_font_collection(utf16_range, &FontCollection::system()); } let family_name = resolve_family_name(&font); @@ -468,7 +468,7 @@ impl D2DTextLayout { if self.needs_to_set_colors.replace(false) { for (range, color) in self.colors.as_ref() { let brush = ctx.solid_brush(*color); - self.layout.borrow_mut().set_foregound_brush(*range, brush) + self.layout.borrow_mut().set_foreground_brush(*range, brush) } } } diff --git a/piet-svg/src/lib.rs b/piet-svg/src/lib.rs index 207b18be..b577064b 100644 --- a/piet-svg/src/lib.rs +++ b/piet-svg/src/lib.rs @@ -280,7 +280,7 @@ impl piet::RenderContext for RenderContext { // // `dominant-baseline` gets us most of the way (to the top of the ascender), so we add a // small fiddle factor in to cover the difference between the top of the line and the top - // of the ascender (currently 6% of the font height, calcuated by eye). + // of the ascender (currently 6% of the font height, calculated by eye). let y = pos.y + 0.06 * layout.size().height; let mut text = svg::node::element::Text::new() .set("x", x) diff --git a/piet-svg/src/text.rs b/piet-svg/src/text.rs index 2b589be6..df266ca8 100644 --- a/piet-svg/src/text.rs +++ b/piet-svg/src/text.rs @@ -286,7 +286,7 @@ impl piet::TextLayout for TextLayout { } } -/// All the info required to indentify a font face. Basically, everythinge except the size. +/// All the info required to identify a font face. Basically, everythinge except the size. #[derive(Debug, Clone, Eq, PartialEq, Hash, Default)] pub(crate) struct FontFace { pub family: FontFamily, diff --git a/piet-web/src/text.rs b/piet-web/src/text.rs index e8b43bc7..05cd415a 100644 --- a/piet-web/src/text.rs +++ b/piet-web/src/text.rs @@ -314,7 +314,7 @@ impl WebTextLayout { fn update_width(&mut self, new_width: impl Into>) { // various functions like `text_width` are stateful, and require - // the context to be configured correcttly. + // the context to be configured correctly. self.ctx.set_font(&self.font.get_font_string()); let new_width = new_width.into().unwrap_or(f64::INFINITY); let mut line_metrics = diff --git a/piet-web/src/text/grapheme.rs b/piet-web/src/text/grapheme.rs index 7c93a9fe..280d7ac2 100644 --- a/piet-web/src/text/grapheme.rs +++ b/piet-web/src/text/grapheme.rs @@ -13,7 +13,7 @@ use super::hit_test_line_position; // code in `piet` core doesn't really make sense as it's implementation specific. // /// get grapheme boundaries, intended to act on a line of text, not a full text layout that has -/// both horizontal and vertial components +/// both horizontal and vertical components pub(crate) fn get_grapheme_boundaries( ctx: &CanvasRenderingContext2d, text: &str, diff --git a/piet/src/gradient.rs b/piet/src/gradient.rs index 8a4d128e..6c922dd9 100644 --- a/piet/src/gradient.rs +++ b/piet/src/gradient.rs @@ -72,7 +72,7 @@ pub struct FixedRadialGradient { /// /// This is provided as a convenience, so that we can provide API that /// accept both [`FixedLinearGradient`] and [`FixedRadialGradient`]. -/// You should not construct this type dirctly; rather construct one of those +/// You should not construct this type directly; rather construct one of those /// types, both of which impl `Into`. #[derive(Debug, Clone)] pub enum FixedGradient { diff --git a/piet/src/image.rs b/piet/src/image.rs index 8b0d00c2..e553608a 100644 --- a/piet/src/image.rs +++ b/piet/src/image.rs @@ -15,7 +15,7 @@ use crate::{Color, ImageFormat, RenderContext}; /// A trait for a backend's bitmap image type. /// -/// This is cheaply clonable. +/// This is cheaply cloneable. pub trait Image: Clone { /// The size of the image fn size(&self) -> Size; diff --git a/piet/src/render_context.rs b/piet/src/render_context.rs index c15acd2a..24f72993 100644 --- a/piet/src/render_context.rs +++ b/piet/src/render_context.rs @@ -110,7 +110,7 @@ where /// The region can be omitted, in which case it will apply to the entire /// canvas. /// - /// This operation ignores any existing clipping and transforations. + /// This operation ignores any existing clipping and transformations. /// /// # Note: /// diff --git a/piet/src/samples/mod.rs b/piet/src/samples/mod.rs index eeb886df..997bdaa8 100644 --- a/piet/src/samples/mod.rs +++ b/piet/src/samples/mod.rs @@ -85,7 +85,7 @@ struct Args { scale: f64, } -/// A shared `main` fn for diferent backends. +/// A shared `main` fn for different backends. /// /// The important thing here is the fn argument; this should be a method that /// takes a number and a path, executes the corresponding sample, and saves a diff --git a/piet/src/samples/picture_12.rs b/piet/src/samples/picture_12.rs index a96cb362..c596f790 100644 --- a/piet/src/samples/picture_12.rs +++ b/piet/src/samples/picture_12.rs @@ -13,7 +13,7 @@ pub const SIZE: Size = Size::new(240., 280.); static TEXT: &str = r#"The idea of "structurelessness," however, has moved from a healthy counter to those tendencies to becoming a goddess in its own right. The idea is as little examined as the term is much used, but it has become an intrinsic and unquestioned part of women's liberation ideology. For the early development of the movement this did not much matter."#; const SELECTION_COLOR: Color = Color::rgb8(165, 205, 255); -const HILIGHT_COLOR: Color = Color::rgba8(255, 242, 54, 96); +const HIGHLIGHT_COLOR: Color = Color::rgba8(255, 242, 54, 96); pub fn draw(rc: &mut R) -> Result<(), Error> { rc.clear(None, Color::WHITE); @@ -40,7 +40,7 @@ pub fn draw(rc: &mut R) -> Result<(), Error> { rc.draw_text(&layout, text_pos.to_point()); for rect in sel_two { - rc.fill(rect + text_pos, &HILIGHT_COLOR); + rc.fill(rect + text_pos, &HIGHLIGHT_COLOR); } Ok(()) diff --git a/piet/src/shapes.rs b/piet/src/shapes.rs index c4f6d385..0e0eff2f 100644 --- a/piet/src/shapes.rs +++ b/piet/src/shapes.rs @@ -12,7 +12,7 @@ use std::rc::Rc; /// /// ## Defaults /// -/// Currently, the style (and its various consituent parts) have [`Default`] +/// Currently, the style (and its various constituent parts) have [`Default`] /// impls that conform to the defaults described in the /// [Postscript Language Manual, 3rd Edition][PLRMv3]; that document is the /// basis for the choice of these types, and can be consulted for detailed @@ -25,7 +25,7 @@ use std::rc::Rc; /// ``` /// use piet::{LineJoin, StrokeStyle}; /// -/// const CONST_STLYE: StrokeStyle = StrokeStyle::new() +/// const CONST_STYLE: StrokeStyle = StrokeStyle::new() /// .dash_pattern(&[5.0, 1.0, 2.0]) /// .line_join(LineJoin::Round); /// diff --git a/piet/src/text.rs b/piet/src/text.rs index 20c3e2fd..9d3b5158 100644 --- a/piet/src/text.rs +++ b/piet/src/text.rs @@ -530,7 +530,7 @@ pub struct HitTestPosition { /// to the baseline of the line containing that grapheme cluster. //FIXME: maybe we should communicate more about this position? for instance //instead of returning an x/y point, we could return the x offset, the line's y_offset, - //and the line height (everything tou would need to draw a cursor) + //and the line height (everything you would need to draw a cursor) pub point: Point, /// The number of the line containing this position. ///